import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Date;

public class a05 {
    public static void main(String[] args) {
        //请使用代码计算你活了多少天，用JDK7和JDK8两种方式完成
        //JDK7
        //规则:只要对时间进行计算和判断，都需要先获取当前时间的毫秒值
        //计算出生年月日的毫秒值
        String birthday="2000年1月1日" ;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        Date birthdayTime = null;

        try {
            birthdayTime = sdf.parse(birthday);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }

        long todayTime = System.currentTimeMillis();
        long time=todayTime-birthdayTime.getTime();
        System.out.println(time/1000/60/60/24);

        //JDK8
        LocalDate ld1=LocalDate.of(2000,1,1);
        LocalDate ld2=LocalDate.now();

        long days=ChronoUnit.DAYS.between(ld1,ld2);
        System.out.println(days);
    }
}
